HAL JPEG types migration

This section provides information about HAL JPEG types and structures for STM32 HAL1 to HAL2 migration.

HAL JPEG callback ID type definition

HAL1

HAL2

typedef enum
{
  HAL_JPEG_ENCODE_CPLT_CB_ID,
  HAL_JPEG_DECODE_CPLT_CB_ID,
  HAL_JPEG_ERROR_CB_ID,
  HAL_JPEG_MSPINIT_CB_ID,
  HAL_JPEG_MSPDEINIT_CB_ID
} HAL_JPEG_CallbackIDTypeDef;
  • Removed from HAL2 : the callback registration is managed by dedicated functions for each JPEG event. For more details, see : HAL JPEG register callback

  • HAL_JPEG_MSPINIT_CB_ID and HAL_JPEG_MSPDEINIT_CB_ID are removed because the functions HAL_JPEG_MspInit() and HAL_JPEG_MspDeInit() are removed. For more details, see : HAL JPEG init configuration details

Related concepts:


HAL JPEG state type definition

Important

  • In HAL1, a single global state machine HAL_JPEG_STATETypeDef manages the entire peripheral states.

  • In HAL2, state management is split into two separate state machines:

    • A global peripheral state machine hal_jpeg_state_t with global states.

    • An encoder state machine hal_jpeg_encode_config_state_t represent the specific encode configuration state.

HAL1

HAL2

typedef enum
{
  HAL_JPEG_STATE_RESET,
  HAL_JPEG_STATE_READY,
  HAL_JPEG_STATE_BUSY,
  HAL_JPEG_STATE_BUSY_ENCODING,
  HAL_JPEG_STATE_BUSY_DECODING,
  HAL_JPEG_STATE_TIMEOUT,
  HAL_JPEG_STATE_ERROR
} HAL_JPEG_STATETypeDef;
 typedef enum
{
  HAL_JPEG_STATE_RESET,
  HAL_JPEG_STATE_IDLE,
  HAL_JPEG_STATE_ACTIVE_ENCODE,
  HAL_JPEG_STATE_ACTIVE_DECODE
} hal_jpeg_state_t;

typedef enum
{
  HAL_JPEG_ENCODE_CONFIG_STATE_RESET,
  HAL_JPEG_ENCODE_CONFIG_STATE_CONFIGURED
} hal_jpeg_encode_config_state_t;

Related concepts:


HAL JPEG configuration type definition

HAL1

HAL2






typedef struct
{
  uint32_t ColorSpace;
  uint32_t ChromaSubsampling;

  uint32_t ImageHeight;
  uint32_t ImageWidth;
  uint32_t ImageQuality;
} JPEG_ConfTypeDef;

In HAL2, ColorSpace and ChromaSubsampling are combined into a single enum hal_jpeg_input_format_t.

For more details, see : HAL JPEG subsampling factors and color space options constants

typedef struct
{
  hal_jpeg_input_format_t input_format;


  uint32_t image_height;
  uint32_t image_width;
  uint32_t image_quality;
} hal_jpeg_config_t;

Related concepts:


HAL JPEG handle type definition

HAL1

HAL2

typedef JPEG_HandleTypeDef;
typedef hal_jpeg_handle_t;

Related concepts: